{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='../../plugin/lottery/template/web/lottery_common_nav'}
    <div class="panel panel-info">
        <div class="panel-heading">当前数量： {$page_total}</div>
        <div class="panel-body">
            <form id="myform" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="web" />
                <input type="hidden" name="r" value="lottery.chance.fans" id="r" />
                <div class="form-group">
                    <label class="col-xs-1 col-sm-1 col-md-1 control-label">用户状态</label>
                    <div class="col-xs-11 col-sm-9 col-md-9">
                        <div class="btn-group">
                            {loop $type_list $row}
                            <a href="{php echo createWebUrlPlugin('lottery.chance.fans',array('themeid'=>$themeid,'type'=>$row['type']));}" class="btn {if $type == $row['type']}btn-primary{else}btn-default{/if}">
                                {$row['title']}
                                <span style="color: #ff0000">{$row['total']}</span>
                            </a>
                            {/loop}
                        </div>
                    </div>
                    {if count($themelist)>1 }
                    <div class="col-xs-12 col-sm-2 col-md-2">
                        <select onchange="submitForm();" class="form-control" name="themeid">
                            {loop $themelist $row}
                            <option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
                            {/loop}
                        </select>
                    </div>
                    {else}
                    <input type="hidden" name="themeid" value="{$themeid}" />
                    {/if}
                </div>

                <div class="form-group">
                    <label class="col-xs-1 col-sm-1 col-md-1 control-label">奖项类型</label>
                    <div class="col-xs-11 col-sm-9 col-md-9">
                        <div class="btn-group">
                            {loop $type_arr $row}
                            <a href="{php echo createWebUrlPlugin('lottery.flag',array('themeid'=>$themeid,'status'=>$row['status'],'p_id'=>$p_id));}" class="btn {if $status == $row['status']}btn-primary{else}btn-default{/if}">
                                {$row['title']}
                                <span style="color: #ff0000">{$row['total']}</span>
                            </a>
                            {/loop}
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-1 col-sm-1 col-md-1 control-label">奖品</label>
                    <div class="col-xs-11 col-sm-9 col-md-9">
                        <div class="btn-group">
                            {loop $prize_arr $row}
                            <a href="{php echo createWebUrlPlugin('lottery.flag',array('themeid'=>$themeid,'p_id'=>$row['p_id'],'status'=>$status));}" class="btn {if $p_id == $row['p_id']}btn-primary{else}btn-default{/if}">
                                {$row['title']}
                                <span style="color: #ff0000">{$row['total']}</span>
                            </a>
                            {/loop}
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">按员工</label>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <select class="form-control" name="workerid">
                            <option value="" >全部</option>
                            {loop $wlist $row}
                               {if $row['workername']}
                                    <option value="{$row['workerid']}" {if $workerid == $row['workerid']} selected='selected'{/if}>
                                        {if $system['is_multiple_merchants']}{$row['companyname']}-{/if}
                                        {if $row['teamname']}{$row['teamname']}-{/if}
                                        {$row['workername']}
                                    </option>
                               {/if}
                            {/loop}
                        </select>
                    </div>

                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">按机会</label>
                    <div class="col-sm-1 col-lg-1 col-md-1 col-xs-1">
                        <select class="form-control" name="chance_type">
                            <option value="0" {if $chance_type == 0 }selected="selected"{/if}>不筛选</option>
                            <option value="1" {if $chance_type == 1 }selected="selected"{/if}>获得机会</option>
                            <option value="2" {if $chance_type == 2 }selected="selected"{/if}>使用机会</option>
                            <option value="3" {if $chance_type == 3 }selected="selected"{/if}>剩余机会</option>
                        </select>
                    </div>

                    <div class="col-sm-1 col-lg-1 col-md-1 col-xs-1">
                        <select class="form-control" name="chance_range">
                            <option value="1" {if $chance_range == 1 }selected="selected"{/if}>等于</option>
                            <option value="2" {if $chance_range == 2 }selected="selected"{/if}>大于</option>
                            <option value="3" {if $chance_range == 3 }selected="selected"{/if}>小于</option>
                            <option value="4" {if $chance_range == 4 }selected="selected"{/if}>大于等于</option>
                            <option value="5" {if $chance_range == 5 }selected="selected"{/if}>小于等于</option>
                        </select>
                    </div>

                    <div class="col-sm-1 col-lg-1 col-md-1 col-xs-1">
                        <select class="form-control" name="chance_num">
                          {php  for($i=1;$i<=$chance_limit;$i++) }
                               <option value="{$i}" {if $chance_num == $i }selected="selected"{/if} >{$i}</option>
                          {php ;}
                        </select>
                    </div>
                </div>

                <div class="form-group clearfix">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
                    <div class="col-sm-4 col-xs-4 col-md-4">
                        <input class="form-control" name="search_data" placeholder="输入报名手机号、微信昵称、客资姓名" type="text" value="{$_P['search_data']}">
                    </div>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                        <input type="hidden" name="__token__" value="{$Request.token}"/>
                    </div>
                    <div class="col-sm-2 col-lg-2 col-md-2 col-xs-2">
                        {if $total<=5000}
                        <input class="btn btn-default" type="submit" name="export_submit" onclick="jump()" id="export_submit" value="导出参与用户">
                        {else}
                        <input class="btn btn-default" type="submit" name="export_submit" onclick="jump()" id="export_submit" value="导出未使用抽奖记录EXCEL(1-5000条)">
                        {/if}
                    </div>
                </div>
            </form>
        </div>
    </div>


    <div class="tab-content">
        <div class="panel panel-default">
            <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width: 50px">UID</th>
                        <th style="width: 100px">昵称</th>
                        <th style="width: 100px">姓名/电话</th>
                        <th style="width: 60px">机会获得</th>
                        <th style="width: 60px">机会使用</th>
                        <th style="width: 60px">机会剩余</th>
                        <th style="width: 260px">奖品</th>
                        <th style="width: 80px">定单状态</th>
                        <th style="width: 80px">员工</th>
                        <th style="width: 160px;text-align: right">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $list $index $item}
                    <tr>
                        <td>{$item['uid']}</td>
                        <td  style="font-size: 10px;max-width: 100px;">
                            <img src="{php echo tomedia($item['avatar']);}" width="28" style="border-radius: 3px;">
                            <br>
                            {$item['nickname']}
                        </td>
                        <td>{$item['username']}<br/>{$item['mobile']}</td>
                        <td>{$item['get_num']}</td>
                        <td>{$item['use_num']}</td>
                        <td>{$item['jihui']}</td>
                        <td>{$item['prize_name']}</td>
                        <td>
                            <span class="label label-{$item['pay_class']}">{$item['pay_txt']}</span>
                        </td>
                        <td>{$item['worker']}</td>
                        <td style="text-align: right">
                            {if $item['fanid']}
                            <a class="btn btn-primary btn-sm" style="width: 35px"  data-type="edit" href="{php echo createWebUrl('comm',array('themeid'=>$themeid,'op'=>'edit','id'=>$item['fanid']));}"
                                         data-edit-url="{php echo createWebUrlPlugin('lottery.chance.add');}" data-themeid="{$item['themeid']}" data-uid="{$item['uid']}"  title="给该用户增加机会" data-toggle="tooltip" data-placement="top">
                                       <i class="fa fa-plus"> </i>
                            </a>
                            {/if}
                            <a href="{php echo createWebUrlPlugin('lottery.chance.main',array('themeid'=>$themeid,'uid'=>$item['uid']));}" class="btn btn-info btn-sm"  title="机会记录" data-toggle="tooltip" data-placement="top">
                                <i class="fa fa-list"> </i>
                            </a>
                            <a href="{php echo createWebUrlPlugin('lottery.flag',array('themeid'=>$themeid,'uid'=>$item['uid']));}" class="btn btn-warning btn-sm"  title="中奖记录" data-toggle="tooltip" data-placement="top">
                                <i class="fa fa-bar-chart"> </i>
                            </a>
                            <a href="{php echo createWebUrl('fanslog', array('op' => 'display','themeid'=>$themeid, 'uid' => $row['uid']));}" class="btn btn-info btn-sm"  title="日志记录" data-toggle="tooltip" data-placement="top"><i class="fa fa-list"> </i></a>
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

{$pager}
<script type="text/javascript">
    $(document).ready(
        function (){

        }
    );

    function jump(){
        layer.msg('正在准备下载');
    }

    function submitForm(){
        $("#r").val('lottery.chance.nouse');
        var form = document.getElementById("myform");
        form.submit();
    }

</script>
